﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Fee.Mapping
{
    public class ConstructionTaskDetailMapping : IEntityTypeConfiguration<ConstructionDetail>
    {
        public void Configure(EntityTypeBuilder<ConstructionDetail> builder)
        {
            builder.HasKey(_ => _.Id);
            builder.Property(_ => _.Id).ValueGeneratedOnAdd();

            builder.Property(_ => _.ContractType);

            builder.Property(_ => _.ConstructionType);
            builder.Property(_ => _.Operator);
            builder.HasOne(_ => _.Contract);

            builder.HasOne(_ => _.Project);
            builder.Property(f => f.Status);
            builder.OwnsOne(_ => _.ProcessInfo, opro =>
            {
                opro.Property(f => f.Number).HasMaxLength(36);
                opro.Property(f => f.ConstructionOperator);
            });

            builder.Property(f => f.TaskId).ValueGeneratedNever(); 

            builder.ToTable("fee_ConstDetail");
        }
    }

}